#pragma once

#include "../arch/a64.h"

OPEN_JLIB_NS


inline f32 scalar_min (f32 a, f32 b) noexcept {
  f32 r;
  asm volatile (R"(
  fmin %s[dst], %s[op1], %s[op2])"
  : [dst]"=x"(r): [op1]"x"(a), [op2]"x"(b));
  return r;
}
inline f32 scalar_max (f32 a, f32 b) noexcept {
  f32 r;
  asm volatile (R"(
  fmax %s[dst], %s[op1], %s[op2])"
  : [dst]"=x"(r): [op1]"x"(a), [op2]"x"(b));
  return r;
}
inline f32 scalar_clamp (f32 v, f32 min, f32 max) noexcept {
  return scalar_min(scalar_max(v, min), max);
}


CLOSE_JLIB_NS

